home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2005 May / CyberMycha 05-2005 (Poland).bin / Immortal / cotndemo.exe / Data1.cab / copwalker.tai < prev    next >
Encoding:
Text File  |  2004-10-29  |  8.1 KB  |  379 lines

  1. //
  2. // COPWalker AI file
  3. //
  4. // Activation behavior:
  5. //  Walker starts out, finds the closest building to activate, goes to it and activates it,
  6. //  then repeats until its lifespan expires, then they disappear into their home 
  7. //  and slack for awhile.
  8. // 
  9. // Visit behavior:
  10. // Walker starts out, finds a building which provides the right service, goes to it and visits,
  11. // then returns home and notes what service level it obtained.
  12. //
  13. // Activation actions:
  14. //  StartActivationRounds - sets start of lifespan (goal data)
  15. //  FindBuildingToActivate - finds the closest building, sets it as the target, and sets a location goal including facing
  16. //        (after which unit goes through generic movement actions, ending up at ReacquireGoal)
  17. //  ActivateBuilding - Performs fidget animates for a set amount of time then activates the building
  18. //  ShouldIActivateAnother - nothing hardcoded - logic for this action is in this file
  19. //  GoHome - sets a location goal of their home building
  20. //        (after which unit goes through generic movement actions, ending up at ReacquireGoal)
  21. //
  22. // Visit actions:
  23. //  StartVisiting - sets start time
  24. //  FindBuildingToVisit - finds the closest appropriate building, sets it as the target, and sets a location goal including facing
  25. //        (after which unit goes through generic movement actions, ending up at ReacquireGoal)
  26. //  VisitBuilding - Performs fidget animates for a set amount of time, getting best service amount from the building
  27. //  ShouldIVisitAnother - nothing hardcoded - logic for this action is in this file
  28. //
  29. // Activation triggers:
  30. //  LifespanExpired - true when the lifespan has expired
  31. //  BuildingActivated - true if building is activated or invalid
  32. //  AtBuildingToActivate - true if we're at our target building and it needs activated
  33. //
  34. // Visit triggers:
  35. //    VisitorGotService - true if walker has received the desired service
  36. //  AtBuildingToVisit - true if we're at a building that provides the desired service
  37.  
  38. #include("Gather.tai")
  39.  
  40. //////////////////////////
  41. // Building & Repairing //
  42. //////////////////////////
  43.  
  44. // assumption here is that there are still some waypoints left
  45. CheckBuildSiteValidity
  46. {
  47.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  48.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  49.     BuildSiteValid true(Advance) false(CheckOwner)
  50. }
  51.  
  52. // assumption here is that there are still some waypoints left
  53. CheckBuildSiteVisibility
  54. {
  55.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  56.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  57.     BuildSiteVisible true(CheckBuildSiteValidity) false(Advance)
  58. }
  59.  
  60. CheckOwner
  61. {
  62.     OwnerIsHuman true(ConvertToLocationGoal)
  63.     OwnerIsComputer true(WaitForBuildSiteToClear)
  64. }
  65.  
  66. // assumption here is that there are no more waypoints
  67. CheckRepairSiteAccessibility
  68. {
  69.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  70.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  71.     RepairIsSpecialUnit true(ChangeTargetForSpecialRepair)
  72.     RepairSiteInRange false(Idle)
  73.     BuildSiteValid true(WaitForBuildSiteToClear) false(CheckOwner)
  74.     NextWaypointRetrieved false(PrepareToMove)
  75. }
  76.  
  77. ConvertToLocationGoal
  78. {
  79.     GoalIsLocation true(PrepareToMove)
  80. }
  81.  
  82. MoveToRepairSite
  83. {
  84.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  85.     anyof(BuildingDestroyed,BuildingRepaired) true(Idle)
  86.     RepairSiteInRange false(PrepareToMove)
  87.     BuildSiteValid true(WaitForBuildSiteToClear) false(ConvertToLocationGoal)
  88. }
  89.  
  90. RepairBuilding
  91. {
  92.     BuildingRepaired true(CheckToMoveIn)
  93.     anyof(BuildingRepaired,BuildingDestroyed) true(Idle)
  94.     anyof(CannotAffordRepair,BuildingNotPaidFor) true(InsufficientResources)
  95.     allof(TakingLightDamage,OwnerIsComputer) true(UnderAttack)
  96. }
  97.  
  98. CheckToMoveIn
  99. {
  100.     ShouldMoveIn true(MoveToNewHome) false(Idle)
  101. }
  102.  
  103. InsufficientResources
  104. {
  105.     AlwaysTrue true(Idle)
  106. }
  107.  
  108. ChangeTargetForSpecialRepair
  109. {
  110.     AlwaysTrue true(MoveToRepairSite)
  111. }
  112.  
  113. TaskSmartCitizen
  114. {
  115.     SmartTaskNotAssigned true(Idle)
  116. }
  117.  
  118. WaitForBuildSiteToClear
  119. {
  120.     allof(BuildingRepaired,GoalIsBuild,BuildQueueEmpty) true(TaskSmartCitizen)
  121.     anyof(BuildingRepaired,BuildingDestroyed) true(Idle)
  122.     RepairIsSpecialUnit true(ChangeTargetForSpecialRepair)
  123.     BuildSiteClear true(RepairBuilding)
  124. }
  125.  
  126.  
  127. /////////////////
  128. // Other Stuff //
  129. /////////////////
  130.  
  131. Idle
  132. {
  133.     BuildingInBuildQueue true(MoveToRepairSite)
  134.     TakingLightDamage true(FleeDanger)
  135. }
  136.  
  137. #include("Generic Attack.tai")
  138.  
  139. // important that this go BEFORE including generic movement
  140. GetNextMoveWaypoint
  141. {
  142.     allof(GoalIsResource,ResourceTargetIsTree,ResourceInRange) true(GatherResource)
  143.     allof(GoalIsStorage,StorageInRange) true(AddResourceToStorage)
  144.     ShouldMoveToNextAutoWaypoint true(GetNextAutoWaypoint)
  145.     allof(GoalIsRepairSite,NextWaypointRetrieved) true(CheckBuildSiteVisibility)
  146.     allof(GoalIsWaitingArea,CanUseThisTileAsWaitingArea) true(MoveToWaitingArea)
  147. }
  148.  
  149. #include("Generic Movement.tai")
  150.  
  151. #include("Generic Death.tai")
  152.  
  153. /////////////////////////////
  154. // Visiting and activating //
  155. /////////////////////////////
  156.  
  157.  
  158. StartActivationRounds
  159. {
  160.     LifespanExpired true(GoHome) false(FindBuildingToActivate)
  161. }
  162.  
  163. StartVisiting
  164. {
  165.     LifespanExpired true(GoHome) false(FindBuildingToVisit)
  166. }
  167.  
  168. ReacquireGoal
  169. {
  170.     allof(GoalIsActivate,AtBuildingToActivate) true(ActivateBuilding)
  171.     allof(GoalIsVisit,AtBuildingToVisit) true(VisitBuilding)
  172.     GoalIsActivate true(Idle)
  173.     GoalIsRepairSite true(CheckRepairSiteAccessibility)
  174.     NewBoatLocation true(GoToBoat)
  175.     allof(GoalIsProduceGoods,JustStandingThere) true(GoHome)
  176. }
  177.  
  178. ActivateBuilding
  179. {
  180.     BuildingActivated true(ShouldIActivateAnother)
  181. }
  182.  
  183. VisitBuilding
  184. {
  185.     VisitorGotService true(ShouldIVisitAnother)
  186.     AtBuildingToVisit false(ShouldIVisitAnother)
  187. }
  188.  
  189.  
  190. ShouldIActivateAnother
  191. {
  192.     LifespanExpired    true(GoHome) false(FindBuildingToActivate)
  193. }
  194.  
  195. ShouldIVisitAnother
  196. {
  197.     anyof(VisitorGotService,LifespanExpired) true(GoHome) false(FindBuildingToVisit)
  198. }
  199.  
  200. TendCrops
  201. {
  202.     LifespanExpired true(Idle)
  203. }
  204.  
  205. PlantCrops
  206. {
  207.     AlwaysTrue true(ReacquireGoal)
  208. }
  209.  
  210. HarvestCrops
  211. {
  212.     AlwaysTrue true(ReacquireGoal)
  213. }
  214.  
  215. ProduceGoods
  216. {
  217.     AtHome false(GoHome)
  218.     ReachedMaximumProduction true(Idle)
  219. }
  220.  
  221. ArriveAtShop
  222. {
  223.     WantToBuySomethingHere true(Barter)
  224.     anyof(IsEvening,IsNight) true(GoHome) false(FindPlaceToShop)
  225. }
  226.  
  227. ArriveHome
  228. {
  229.     AlwaysTrue true(Idle)
  230. }
  231.  
  232. Barter
  233. {
  234.     FinishedBartering true(FinishBarterTransaction)
  235.     IsNight true(GoHome)
  236. }
  237.     
  238. // Note: Home may mean 'shop' for servants
  239. FinishBarterTransaction
  240. {
  241.     GoalIsVault true(GoHome)
  242.     anyof(IsEvening,IsNight) true(GoHome) false(FindPlaceToShop)
  243. }
  244.  
  245. Migrate
  246. {
  247.     TakingLightDamage true(FleeDanger)
  248. }
  249.  
  250. WaitToMigrate
  251. {
  252.     BuildingBuilt true(Migrate)
  253. }
  254.  
  255. GoToSchool
  256. {
  257.     LifespanExpired true(GoHome)
  258. }
  259.  
  260. Beg
  261. {
  262.     LifespanExpired true(SearchForBegTarget)
  263. }
  264.  
  265. GiveToBeggar
  266. {
  267.     LifespanExpired true(FinishGivingToBeggar)
  268. }
  269.  
  270. FinishGivingToBeggar
  271. {
  272.     TakingLightDamage true(FleeDanger)
  273. }
  274.     
  275. BuildShack
  276. {
  277.     TakingLightDamage true(FleeDanger)
  278. }
  279.  
  280. PlanMovement
  281. {
  282.     TakingLightDamage true(FleeDanger)
  283. }
  284.  
  285. InteriorAdvance
  286. {
  287.     TakingLightDamage true(FleeDanger)
  288. }
  289.  
  290. MakeTreasure
  291. {
  292.     TakingLightDamage true(FleeDanger)
  293. }
  294.  
  295. Follow
  296. {
  297.     TargetInRange true(WaitToFollow)
  298. }
  299.  
  300. WaitToFollow
  301. {
  302.     TargetInRange false(Follow)
  303. }
  304.  
  305. BuyFood
  306. {
  307.     TakingLightDamage true(FleeDanger)
  308. }
  309.  
  310. HaulSled
  311. {
  312.     TakingLightDamage true(FleeDanger)
  313. }
  314.  
  315. MoveBricks
  316. {
  317.     TakingLightDamage true(FleeDanger)
  318. }
  319.  
  320. MoveToSled
  321. {
  322.     TakingLightDamage true(FleeDanger)
  323. }
  324.  
  325. Quarry
  326. {
  327.     TakingLightDamage true(FleeDanger)
  328. }
  329.  
  330. PlanRiverCrossing
  331. {
  332.     JustStandingThere true(ReacquireGoal)
  333. }
  334.  
  335. BuildBoat
  336. {
  337.     TakingLightDamage true(FleeDanger)
  338. }
  339.  
  340. BoatBuilt
  341. {
  342.     TakingLightDamage true(FleeDanger)
  343. }
  344.  
  345. ReadyForBoarding
  346. {
  347.     TakingLightDamage true(FleeDanger)
  348. }
  349.  
  350. StartPatrol
  351. {
  352.     TakingLightDamage true(UnderAttack)
  353. }
  354.  
  355. Chat
  356. {
  357.     StillChatting false(TurnBackToWork)
  358.     FacingChatPartner false(TurnToChatPartner)
  359. }
  360.  
  361. TurnToChatPartner
  362. {
  363.     FacingChatPartner true(Chat)
  364. }
  365.  
  366. TurnBackToWork
  367. {
  368.     TurnComplete true(ReacquireGoal)
  369. }
  370.  
  371. GoHome
  372. {
  373.     JustStandingThere true(ReacquireGoal)
  374. }
  375.  
  376. WaitForHaulers
  377. {
  378.     HaulersArrived true(StartBeingHauled)
  379. }